//
//  ImageUploadModel.swift
//  Exam-iOS
//
//  Created by lishengfeng on 2018/3/11.
//  Copyright © 2018年 李胜锋. All rights reserved.
//

import Foundation
import ObjectMapper

class ImageUploadModel: NSObject, Mappable, NSCoding, Storagable {
    
    var expiration: String?
    var accessKeyId: String?
    var accessKeySecret: String?
    var securityToken: String?
    var bucket: String?
    var urlPri: String?
    
    required init?(map: Map) { }
    required override init() { }
    
    func mapping(map: Map) {
        expiration <- map["expiration"]
        accessKeyId   <- map["accessKeyId"]
        accessKeySecret  <- map["accessKeySecret"]
        securityToken <- map["securityToken"]
        bucket  <- map["bucket"]
        urlPri  <- map["urlPri"]
    }
    
    
    public func encode(with aCoder: NSCoder) {
    
        aCoder.encode(expiration, forKey: "expiration")
        aCoder.encode(accessKeyId, forKey: "accessKeyId")
        aCoder.encode(accessKeySecret, forKey: "accessKeySecret")
        aCoder.encode(securityToken, forKey: "securityToken")
        aCoder.encode(bucket, forKey: "bucket")
        aCoder.encode(urlPri, forKey: "urlPri")
    }
    
    required init?(coder aDecoder: NSCoder) {
        self.expiration = aDecoder.decodeObject(forKey: "expiration") as? String
        self.accessKeyId = aDecoder.decodeObject(forKey: "accessKeyId") as? String
        self.accessKeySecret = aDecoder.decodeObject(forKey: "accessKeySecret") as? String
        self.securityToken = aDecoder.decodeObject(forKey: "securityToken") as? String
        self.bucket = aDecoder.decodeObject(forKey: "bucket") as? String
        self.urlPri = aDecoder.decodeObject(forKey: "urlPri") as? String
    }
    
    func dic() -> [String: String] {
        
        let dic = ["expiration": expiration!,
                   "accessKeyId": accessKeyId!,
                   "accessKeySecret": accessKeySecret!,
                   "securityToken": securityToken!,
                   "bucket": bucket!,
                   "urlPri": urlPri!]
        return dic
    }
}


